package com.dac.learn.springboot.validation.user;

import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangdc
 * @date 2025/8/27
 */
@RestController
@RequestMapping("/api/users")
public class UserController {

    @PostMapping("/register")
    public ResponseEntity<String> registerUser(@Valid @RequestBody UserDTO userDTO) {
        // 如果 UserDTO 通过了所有验证，代码会执行到这里
        System.out.println("收到用户注册请求: " + userDTO);
        return ResponseEntity.ok("用户注册成功: " + userDTO.getUsername());
    }
}

